<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="oms" uri="/WEB-INF/oms-el.tld"%>
<link rel="stylesheet" type="text/css" href="${oms:static() }/dtree/dtree.css">
<script type="text/javascript">
var d = new dTree('d');
	$(function(){
		//d.add(100,-1,"系统管理员");//根节点的父节点必须为-1；
		<c:forEach var="prize" items="${prizes}" varStatus="status">
			<c:if test="${prize.status==2}">
				d.add(<c:out value="${prize.id }" />,-1,"<c:out value="${prize.prizeName }" />","", "roleList");
			</c:if>
		</c:forEach>
		$("#dtree").html(d.toString());
		$("#saveButton").click(function(){
			getCheckedNodesId();
			myDialog.close();
		});
	});

</script>
			<form  method="post" id="form" action="">
				<ul class="all_list">
						<li class="clearfix">
							<span class="all_title l">奖品列表：</span>
							<span class="l">
							<div class="dtreediv" style="height:450px;width:350px;"><div id="dtree" style="margin-left: 8px;"></div></div>
							</span>
						</li>
						<li>
							<span class="all_title"></span>
							<span><input type="button" id="saveButton" class="btn_blue" name="saveButton"
								value="确认"></span>
						</li>
						<c:forEach var="prizeId" items="${mySelectPrizeIdList}">
							<input name="myPrizeList" type="hidden" value="<c:out value='${prizeId}' />" />
						</c:forEach>
				</ul>
			</form>
			<script type="text/javascript">
			$(function(){
				$('input[name="myPrizeList"]').each(function(){
					 $('#'+$(this).val()).attr("checked",true);
				});  
			});
			
				function getCheckedNodesId() {
					var str="";
					var s = "";
					$("input[type='checkbox']:checked").each(function() {
						str+= $(this).attr("id")+",";
						s += $(this).parent().find("label").html()+",";
					});
					$('#productIds', window.parent.document).attr("value",str.slice(0,str.length-1));
					$('#prizeList', window.parent.document).attr("value",s.slice(0,s.length-1));
				}
			</script>

